define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope,$rootScope, T_address_add_fp_buyer, GoPage, $stateParams, GoDialog) {
		$scope.scope = new Object();
		$scope.id = $stateParams.id;
		$scope.datas = new Object();
		GoPage.init_top($scope);
		//不需要假数据
		$scope.init_data = function() {
			T_address_add_fp_buyer.invoice_detail($scope.id, function(data) {
				$scope.datas = data;
			})
		}
		$scope.init_data(); //必须在定义之后
		
		$scope.onshow_address = function() {
			T_address_add_fp_buyer.invoice_edit($scope.datas.tax_ratio1, $scope.datas.tax_ratio2,function(data) {
				$scope.data = data;
				if($scope.data.success ) {
					GoDialog.toast("保存成功！")
					GoPage.go_back(-1); //返回上一页
					//注册了全局广播
					$rootScope.$broadcast('editSettingEvent');
				} else{
					alert(data.msg);
				}
			})
		}
		
	}

	controller.$inject = ['$scope','$rootScope', 'T_address_add_fp_buyer', 'GoPage', '$stateParams', 'GoDialog'];

	return app.registerController("address_add_fp_buyerctrl",controller);
});